package elizabethMahon;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.io.InputStreamReader;
import java.io.BufferedReader;

class urlreader
{
	public void readURL(String url)
	{
		try {
			URL place = new URL(url);
			InputStream basic_conn = place.openStream();
			InputStreamReader reader = new InputStreamReader(basic_conn);
			BufferedReader data = new BufferedReader(reader);
			String line;
			
			while((line = data.readLine()) != null)
			{
				System.out.println(line);
			}
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

public class Homework8
{
	public static void main(String[] args)
	{
		String blah = "blah<a href=\"http://www.serebii.net/index2.html\">link text here</a>";
		String ahref = "<a [a-z]*=\"[a-z./:0-9]*\">";
		int i = 0;

		System.out.println(blah);
		for (String s:blah.split(ahref))
		{
			System.out.println(s + " "+ i);
			i++;
			for(String q:s.split("</a>"))
			{
				System.out.println(q);
			}
		}
		
		urlreader q = new urlreader();
		
		q.readURL("http://www.serebii.net");
	}
}